'use strict'

import {
    app,
    BrowserWindow,
    Menu
} from 'electron'
// import { app, BrowserWindow } from 'electron'

/**
 * Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== 'development') {
  global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}

// const electron = require('electron')
let mainWindow
const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`

function createWindow () {
  /**
    * Initial window options
    */
  // var itemSize = electron.screen.getPrimaryDisplay().workAreaSize
  mainWindow = new BrowserWindow({
    // height: itemSize.height,
    // width: itemSize.width,
    height: 720,
    width: 1280,
    useContentSize: true
  })
  mainWindow.setFullScreen(true)

  // mainWindow.webContents.openDevTools()

  Menu.setApplicationMenu(null)

  mainWindow.loadURL(winURL)

  mainWindow.on('closed', () => {
    mainWindow = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (mainWindow === null) {
    createWindow()
  }
})
